﻿<UserControl x:Class="VKontakteClient.AudioSearchControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Local="clr-namespace:VKontakteClient"
    MinHeight="100" MinWidth="250" DataContextChanged="DCChanged">
    <Border Background="AliceBlue" BorderBrush="Black" BorderThickness="1" CornerRadius="10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Right" Margin="5" Orientation="Horizontal">
                <Button Content=" Загрузить полный список " Click="Button_Click" />
                <CheckBox Content="Убрать повторы" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" VerticalAlignment="Center" Margin="10,0,10,0" />
                <TextBlock Text="Поиск: " HorizontalAlignment="Center" VerticalAlignment="Center" />
                <TextBox Width="100" x:Name="SearchTextBox" />
                <Button Content=">" Click="Search" IsEnabled="True" />
            </StackPanel>

            <ItemsControl Grid.Row="1" ScrollViewer.CanContentScroll="True" ScrollViewer.IsDeferredScrollingEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Visible" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" x:Name="audios" VirtualizingStackPanel.IsVirtualizing="True"  VirtualizingStackPanel.VirtualizationMode="Recycling">
                <ItemsControl.Template>
                    <ControlTemplate TargetType="ItemsControl">
                        <ScrollViewer CanContentScroll="True" IsDeferredScrollingEnabled="True">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </ControlTemplate>
                </ItemsControl.Template>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                            <Local:AudioControl DataContext="{Binding Audio}" Margin="5" HorizontalAlignment="Stretch" Height="50" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
    </Border>
</UserControl>
